<?php session_start(); /*Added by suwondo*/ ?>
<?php require('connections/con_gl.php'); ?>
<?php
cekAkses($_SESSION[akses],"JS-6");
$currentPage = $_SERVER["PHP_SELF"];
?>
<script type="text/javascript" src="js/jquery-1.4.js"></script>
<script type="text/javascript" src="js/jquery.autocomplete.js"></script>
<link rel="stylesheet" type="text/css" href="css/jquery.autocomplete.css" />
<h1>Data Master Kendaraan</h1>
<table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable">
	<tr valign="top" bgcolor="#FFFFFF" class="hide">
        <td colspan="16" align="right" style="border-bottom:solid 1px #E2EAC1;border-right:solid 1px #E2EAC1;">
			<form id="search" name="search" method="post" action="">
			<!-- Edit by suwondo -->
			  Cari data : 
				<label>
					<input name="cr_txt" type="text" id="cr_txt" placeholder="Find by: no polisi, kode asset, merk, tipe & status" onclick="this.select(); $(this).autocomplete('components/masterkendaraan/search.autocomplete.php', { width: 330 });" size="45" maxlength="100" onkeyup="javascript: $(this).autocomplete('components/masterkedaraan/search.autocomplete.php', { width: 330 }); $(this).result(function(event, data, formatted){ idx = formatted.split(' - '); window.location.href='index.php?component=masterkendaraan&task=listnew&open=window&cr_kel=ALL&cr_txt='+idx[0]; });" <?php echo $_REQUEST['cr_txt'];?> />
				</label>
				<label><input name="Search" type="submit" id="Search" value="Refresh" /></label>
			</form>
		<?php
		if(isset($_POST['Search'])) {
			echo "<script>window.location=\"index.php?component=masterkendaraan&task=listnew&open=window&cr_kel=ALL&cr_txt=".str_replace(" ","+",$_POST[cr_txt])."\";</script>";
		}
		?>		</td>
	</tr>
	<tr>
		<th width="86"><strong>No.Polisi</strong></th>
		<th width="85">Kode Asset </th>
		<th width="147">Merk</th>
		<th width="388">Tipe</th>
		<th width="43">Tahun</th>
		<th width="160">Cabang</th>
		<th width="154">Area Ops </th>
		<th width="84">Status</th>
		<th width="80" align="center" class="hide"><strong>Aksi</strong></th>
	</tr>
	<?php
	$key = trim($_REQUEST['cr_txt']);
	$str = "SELECT gl_masterkendaraan.id, gl_masterkendaraan.nopolisi, gl_masterkendaraan.kodeasset, gl_merkkendaraan.merk, gl_tipekendaraan.tipekendaraan, gl_masterkendaraan.tahun, gl_gudang.gudang, gl_area.area, gl_statuskendaraan.status from gl_masterkendaraan, gl_merkkendaraan, gl_tipekendaraan, gl_area, gl_gudang, gl_statuskendaraan WHERE gl_merkkendaraan.id = gl_masterkendaraan.merk AND gl_tipekendaraan.id = gl_masterkendaraan.tipekendaraan AND gl_area.id = gl_masterkendaraan.area AND gl_gudang.id = gl_masterkendaraan.cabang AND gl_statuskendaraan.id = gl_masterkendaraan.status AND nopolisi like '%$key%' ";
	if(!strstr($_SESSION[akses],'A-1-4')) {
	$str .= " and gl_masterkendaraan.cabang = '$_SESSION[lokasi]' ";
	}
	$str .= " order by id asc";
	$query = mysql_query($str) or die (mysql_error());
		while(list($id, $nopolisi, $kodeasset, $merk, $tipe, $tahun, $gudang, $area, $status) = mysql_fetch_row($query)){
		echo "<tr>";
		echo "<td>$nopolisi</td><td>$kodeasset</td><td>$merk</td><td>$tipe</td><td>$tahun</td><td>$gudang</td><td>$area</td><td>$status</td><td align='center'><input type='button' value='pilih' onclick=\"javascript: window.opener.document.getElementById('nopolisi').value='$id'; window.opener.document.getElementById('txtnopolisi').value='$nopolisi'; window.close(1000);\" /></td>";
		echo "</tr>";
	}
	?>
 </table>
